//
//  NSObject+Extension.m
//  Project
//
//  Created by 郑键 on 17/1/11.
//  Copyright © 2017年 zhengjian. All rights reserved.
//

#import "NSObject+Extension.h"
#import <mach/mach_time.h>

@implementation NSObject (Extension)

/**
 查看代码执行时间
 
 @param block 需要执行的代码块
 */
- (void)ex_codeExecutionTimeWithBlock:(ZJEventCallBackBlock)block
{
    uint64_t start = mach_absolute_time();
    
    block(nil);
    
    uint64_t end = mach_absolute_time();
    uint64_t elapsed = end - start;mach_timebase_info_data_t info;
    if (mach_timebase_info (&info) != KERN_SUCCESS)
    {
        printf ("mach_timebase_info failed\n");
    }
    uint64_t nanosecs = elapsed * info.numer / info.denom;
    uint64_t millisecs = nanosecs / 1000000;
    NSLog(@">>>>>>>>>>cost time = %zd ms", millisecs);
}

@end
